package com.jinhongone.pattern.behavior.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jinho
 * @className OwnerHome
 * @description 结构对象
 * @date 2025/4/17 10:20
 */
public class OwnerHome {
    //    结构对象存储元素
    private List<Animal> animalList = new ArrayList<>();

    //访问者访问元素
    public void action(Person person) {
        for (Animal animal : animalList) {
            animal.accept(person);
        }
    }

    public void add(Animal animal) {
        animalList.add(animal);
    }

}
